package com.eduction.modules.system.dao;

import com.eduction.common.dbutil.DbHelper;
import com.eduction.modules.system.entity.ApplyFileBase;
import com.eduction.modules.system.entity.ApplyFileBaseDetail;
import com.eduction.modules.system.entity.ApplyFileBaseScore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

@Repository
public class ApplyFileBaseScoreRepository {

	@Autowired
	private DbHelper dbHelper;
	@Autowired
	private ApplyFileBaseScoreDao applyFileBaseScoreDao;

	/**
	 * 查询学校自评表基础信息评分
	 * @throws SQLException
	 */
	public ApplyFileBaseScore queryApplyFileBaseScoreBySchoolId(String schoolId) throws SQLException{
		String sql = "SELECT * FROM t_apply_file_base_score where school_id = ? ";
		return dbHelper.getBean(sql, ApplyFileBaseScore.class, schoolId);

	}

	/**
	 * 保存该校的自评表基础信息评分
	 */
	public void saveAppplyFileBaseScore(ApplyFileBaseScore a) throws SQLException{
		ApplyFileBaseScore base=queryApplyFileBaseScoreBySchoolId(a.getSchoolId());
		if(base!=null&&base.getId()!=null){
			applyFileBaseScoreDao.delete(base.getId());
		}
		applyFileBaseScoreDao.save(a);
	}

}
